home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 13636 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.4 KB

  1. Path: mail2news.demon.co.uk!genesis.demon.co.uk
  2. From: Lawrence Kirby <fred@genesis.demon.co.uk>
  3. Newsgroups: comp.lang.c
  4. Subject: Re: reversing a string
  5. Date: Tue, 09 Apr 96 14:01:54 GMT
  6. Organization: none
  7. Message-ID: <829058514snz@genesis.demon.co.uk>
  8. References: <4k6cjl$j8f@central.server.swt.edu> <4kb1s7$6eu@ibm32.perftech.com>
  9. Reply-To: fred@genesis.demon.co.uk
  10. X-NNTP-Posting-Host: genesis.demon.co.uk
  11. X-Newsreader: Demon Internet Simple News v1.27
  12. X-Mail2News-Path: genesis.demon.co.uk
  13.  
  14. In article <4kb1s7$6eu@ibm32.perftech.com>
  15.            murf@perftech.com "John Murphy" writes:
  16.  
  17. >In article <4k6cjl$j8f@central.server.swt.edu>, ln16674@nyssa.swt.edu 
  18. >says...
  19. >>
  20. >>I have a challenge from a friend of mine.  He wanted me to reverse a string 
  21. >>with recursion without using any additional variables or loops.  I got mine
  22. >>to work by using exclusive or, but I needed an additional variable.  Can 
  23. >>someone help with this problem without using the additional variable?
  24. >>
  25. >>Thanks
  26. >You can swap two variables, x and y, with the following series of exclusive 
  27. >or's:
  28. >        x ^= y;
  29. >        y ^= x;
  30. >        x ^= y;
  31.  
  32. From what he wrote I believe Leland was already doing that. The problem is
  33. to write the entire function without using an additional variable. It
  34. can be done! :-)
  35.  
  36. -- 
  37. -----------------------------------------
  38. Lawrence Kirby | fred@genesis.demon.co.uk
  39. Wilts, England | 70734.126@compuserve.com
  40. -----------------------------------------
  41.